#
# Copyright 2008 Wepoco.  http://www.wepoco.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import cgi
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp

from template import header, footer 

class ListAction(webapp.RequestHandler):
  def post(self):

    form = cgi.FieldStorage()
    self.items = form.getlist('a')

    if form.getvalue('act_bu_go') == 'Go':
      action = form.getvalue('act_sel')
      if action == "ren":
        for item in self.items:
          self.response.out.write("<p>ren %s</p>" % item)
          pass
      elif action == "pub":
        for item in self.items:
          track = db.get(db.Key(item))
          track.isPublic = True
          track.put()
          pass
        pass
      elif action == "pri":
        for item in self.items:
          track = db.get(db.Key(item))
          track.isPublic = False
          track.put()
          pass
        pass
      elif action == "del":
        for item in self.items:
          db.delete(db.get(db.Key(item)))
          pass
        pass
      else:
        pass
      pass
    self.redirect('/')
    return

